#!/usr/bin/env bash
echo dev > config_ns
echo dev > config_md
CONFIG_MODE_TEXT=`cat ./config_md`
if [ "$CONFIG_MODE_TEXT" = "dev" ];then
	current_port=3200

elif [ "${CONFIG_MODE_TEXT}" = "online" ];then
	current_port=3128

fi

sudo docker run \
    --name vagrant-${CONFIG_MODE_TEXT} \
    --dns=8.8.8.8 \
    --add-host dev.swoole.com:127.0.0.1 \
    --add-host www.vagrant.com:127.0.0.1 \
    --add-host backend.vagrant.com:127.0.0.1 \
    --add-host api.vagrant.com:127.0.0.1 \
    --privileged=true \
    -e TZ=Asia/Shanghai \
    --cap-add SYS_PTRACE \
    -v `pwd`/etc/${CONFIG_MODE_TEXT}/nginx/conf.d:/etc/nginx/conf.d \
    -v `pwd`/etc/${CONFIG_MODE_TEXT}/nginx/nginx.conf:/etc/nginx/nginx.conf \
    -v `pwd`/etc/${CONFIG_MODE_TEXT}/supervisor/conf.d:/etc/supervisor/conf.d  \
    -v `pwd`/etc/${CONFIG_MODE_TEXT}/supervisord.conf/:/etc/supervisord.conf \
    -v `(cd ../;pwd)`/:/usr/share/nginx/html \
    -p ${current_port}:3128 \
    -d \
    751836594/vagrant \
    supervisord -c /etc/supervisord.conf
